<template>
  <!-- 合子居中 -->
  <div class="flex justify-center items-center h-screen">
    <div>
      <h1 class="text-3xl font-bold">这是主页！</h1>
      <el-button @click="to" class="mt-4">前往</el-button>
      <el-button @click="getArticleList" class="mt-4">获取</el-button>
    </div>
  </div>
</template>
<script setup lang="ts">
import { getArticleApi } from '@/api/test'
import { HotArticleQuery, HotArticleVo } from '@/api/test'
import { Page } from '@/api/page'
import { router } from '@/router';
import { reactive, ref } from 'vue';

const query = reactive<HotArticleQuery>({
  pageIndex: 1,
  pageSize: 10,
  searchKey: ''
})

const articleData = ref<Page<HotArticleVo>>();

function getArticleList() {
  getArticleApi(query).then(res => {
    articleData.value = res.data
    console.log(articleData.value.records)
    console.log(articleData.value.total)
  })
}

function to() {
  console.log("点击跳转了");
  router.push('/about')
}
</script>
